package yk.com.AllMenu;

import yk.com.StudentManager;
import java.util.Scanner;

public class QueryStudent {
    public static void execute(Scanner scanner) {
        // 显示查询菜单
        displayQueryMenu();
        System.out.print("请输入您的选择: ");
        int queryChoice = scanner.nextInt();
        scanner.nextLine(); // 清除输入缓冲区

        // 根据查询选择执行操作
        switch (queryChoice) {
            case 1:
                showAllStudents();
                break;
            case 2:
                System.out.print("请输入要查询学生的学号: ");
                String id = scanner.nextLine();
                showStudentById(id);
                break;
            default:
                System.out.println("无效的选择，请重新输入！");
                break;
        }
    }

    // 显示查询菜单
    private static void displayQueryMenu() {
        System.out.println("-----查询学生-----");
        System.out.println("1. 查询所有学生");
        System.out.println("2. 按照学号查询学生");
    }

    // 查看所有学生
    private static void showAllStudents() {
        StudentManager.showAllStudents();
    }

    // 按照学号查询学生
    private static void showStudentById(String id) {
        StudentManager.showStudentById(id);
    }
}